﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YhmOA.Common;
using System.Text;

namespace YhmOA.Framework
{
    public partial class Main : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //<dl open="false" id="__个人办公" onclick="RoleVerification('个人办公');">
            //    <dd class="topmenuboth"></dd>
            //    <dd class="topmenucontent">个人办公</dd>
            //    <dd class="topmenuboth"></dd>
            //    <dd class="topmenuline"></dd>
            //</dl>
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            List<string> list = MenuConfig.GetTopMenu();
            StringBuilder builder = new StringBuilder();
            foreach (string item in list)
            {
                builder.AppendLine("<dl open=\"false\" id=\"__" + item + "\" onclick=\"RoleVerification('" + item + "');\">");
                builder.AppendLine("\t<dd class=\"topmenuboth\"></dd>");
                builder.AppendLine("\t<dd class=\"topmenucontent\">" + item + "</dd>");
                builder.AppendLine("\t<dd class=\"topmenuboth\"></dd>");
                builder.AppendLine("\t<dd class=\"topmenuline\"></dd>");
                builder.AppendLine("</dl>");
            }
            this.ltContent.Text = builder.ToString();
        }

        [AjaxMethod]
        public void RoleVerification(string name)
        {
            bool flag = true;
            if (name == "日程任务" || name == "业务管理" || name == "档案管理" || name == "人力资源")
            {
                flag = false;
            }
            if (flag)
            {
                ExecClientScript("ShowHideMenu('__" + name + "');$('.iframeleftmenu').children().eq(0).attr('src', '/Framework/left.aspx?xml=' + encodeURIComponent('" + name + "'));");
            }
            else
            {
                MessageBox("您没有权限");
            }
        }
    }
}